home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / man / lib.fmt / c / execve.man < prev    next >
Encoding:
Text File  |  1989-02-16  |  7.8 KB  |  265 lines

  1.  
  2.  
  3.  
  4. EXECVE                C Library Procedures                 EXECVE
  5.  
  6.  
  7.  
  8. NNAAMMEE
  9.      execve - execute a file
  10.  
  11. SSYYNNOOPPSSIISS
  12.      eexxeeccvvee((nnaammee,, aarrggvv,, eennvvpp))
  13.      cchhaarr **nnaammee,, **aarrggvv[[]],, **eennvvpp[[]];;
  14.  
  15. DDEESSCCRRIIPPTTIIOONN
  16.      _E_x_e_c_v_e transforms the calling process into a new process.
  17.      The new process is constructed from an ordinary file called
  18.      the _n_e_w _p_r_o_c_e_s_s _f_i_l_e.  This file is either an executable
  19.      object file, or a file of data for an interpreter.  An exe-
  20.      cutable object file consists of an identifying header, fol-
  21.      lowed by pages of data representing the initial program
  22.      (text) and initialized data pages.  Additional pages may be
  23.      specified by the header to be initialized with zero data.
  24.      See _a._o_u_t(5).
  25.  
  26.      An interpreter file begins with a line of the form ``#!
  27.      _i_n_t_e_r_p_r_e_t_e_r''.  When an interpreter file is _e_x_e_c_v_e'd, the
  28.      system _e_x_e_c_v_e's the specified _i_n_t_e_r_p_r_e_t_e_r, giving it the
  29.      name of the originally exec'd file as an argument and shift-
  30.      ing over the rest of the original arguments.
  31.  
  32.      There can be no return from a successful _e_x_e_c_v_e because the
  33.      calling core image is lost.  This is the mechanism whereby
  34.      different process images become active.
  35.  
  36.      The argument _a_r_g_v is a null-terminated array of character
  37.      pointers to null-terminated character strings.  These
  38.      strings constitute the argument list to be made available to
  39.      the new process.  By convention, at least one argument must
  40.      be present in this array, and the first element of this
  41.      array should be the name of the executed program (i.e., the
  42.      last component of _n_a_m_e).
  43.  
  44.      The argument _e_n_v_p is also a null-terminated array of charac-
  45.      ter pointers to null-terminated strings.  These strings pass
  46.      information to the new process that is not directly an argu-
  47.      ment to the command (see _e_n_v_i_r_o_n(7)).
  48.  
  49.      Descriptors open in the calling process remain open in the
  50.      new process, except for those for which the close-on-exec
  51.      flag is set (see _c_l_o_s_e(2)).  Descriptors that remain open
  52.      are unaffected by _e_x_e_c_v_e.
  53.  
  54.      Ignored signals remain ignored across an _e_x_e_c_v_e, but signals
  55.      that are caught are reset to their default values.  Blocked
  56.      signals remain blocked regardless of changes to the signal
  57.      action.  The signal stack is reset to be undefined (see
  58.      _s_i_g_v_e_c(2) for more information).
  59.  
  60.  
  61.  
  62.  
  63. Sprite v1.0               May 22, 1986                          1
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. EXECVE                C Library Procedures                 EXECVE
  71.  
  72.  
  73.  
  74.      Each process has _r_e_a_l user and group IDs and an _e_f_f_e_c_t_i_v_e
  75.      user and group IDs.  The _r_e_a_l ID identifies the person using
  76.      the system; the _e_f_f_e_c_t_i_v_e ID determines his access
  77.      privileges.  _E_x_e_c_v_e changes the effective user and group ID
  78.      to the owner of the executed file if the file has the "set-
  79.      user-ID" or "set-group-ID" modes.  The _r_e_a_l user ID is not
  80.      affected.
  81.  
  82.      The new process also inherits the following attributes from
  83.      the calling process:
  84.  
  85.           process ID          see _g_e_t_p_i_d(2)
  86.           parent process ID   see _g_e_t_p_p_i_d(2)
  87.           process group ID    see _g_e_t_p_g_r_p(2)
  88.           access groups       see _g_e_t_g_r_o_u_p_s(2)
  89.           working directory   see _c_h_d_i_r(2)
  90.           root directory      see _c_h_r_o_o_t(2)
  91.           control terminal    see _t_t_y(4)
  92.           resource usages     see _g_e_t_r_u_s_a_g_e(2)
  93.           interval timers     see _g_e_t_i_t_i_m_e_r(2)
  94.           resource limits     see _g_e_t_r_l_i_m_i_t(2)
  95.           file mode mask      see _u_m_a_s_k(2)
  96.           signal mask         see _s_i_g_v_e_c(2), _s_i_g_m_a_s_k(2)
  97.  
  98.      When the executed program begins, it is called as follows:
  99.  
  100.           main(argc, argv, envp)
  101.           int argc;
  102.           char **argv, **envp;
  103.  
  104.      where _a_r_g_c is the number of elements in _a_r_g_v (the ``arg
  105.      count'') and _a_r_g_v is the array of character pointers to the
  106.      arguments themselves.
  107.  
  108.      _E_n_v_p is a pointer to an array of strings that constitute the
  109.      _e_n_v_i_r_o_n_m_e_n_t of the process.  A pointer to this array is also
  110.      stored in the global variable ``environ''.  Each string con-
  111.      sists of a name, an "=", and a null-terminated value.  The
  112.      array of pointers is terminated by a null pointer.  The
  113.      shell _s_h(1) passes an environment entry for each global
  114.      shell variable defined when the program is called.  See
  115.      _e_n_v_i_r_o_n(7) for some conventionally used names.
  116.  
  117. RREETTUURRNN VVAALLUUEE
  118.      If _e_x_e_c_v_e returns to the calling process an error has
  119.      occurred; the return value will be -1 and the global vari-
  120.      able _e_r_r_n_o will contain an error code.
  121.  
  122. EERRRROORRSS
  123.      _E_x_e_c_v_e will fail and return to the calling process if one or
  124.      more of the following are true:
  125.  
  126.  
  127.  
  128.  
  129. Sprite v1.0               May 22, 1986                          2
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. EXECVE                C Library Procedures                 EXECVE
  137.  
  138.  
  139.  
  140.      [ENOTDIR]      A component of the path prefix is not a
  141.                     directory.
  142.  
  143.      [EINVAL]       The pathname contains a character with the
  144.                     high-order bit set.
  145.  
  146.      [ENAMETOOLONG] A component of a pathname exceeded 255 char-
  147.                     acters, or an entire path name exceeded 1023
  148.                     characters.
  149.  
  150.      [ENOENT]       The new process file does not exist.
  151.  
  152.      [ELOOP]        Too many symbolic links were encountered in
  153.                     translating the pathname.
  154.  
  155.      [EACCES]       Search permission is denied for a component
  156.                     of the path prefix.
  157.  
  158.      [EACCES]       The new process file is not an ordinary file.
  159.  
  160.      [EACCES]       The new process file mode denies execute per-
  161.                     mission.
  162.  
  163.      [ENOEXEC]      The new process file has the appropriate
  164.                     access permission, but has an invalid magic
  165.                     number in its header.
  166.  
  167.      [ETXTBSY]      The new process file is a pure procedure
  168.                     (shared text) file that is currently open for
  169.                     writing or reading by some process.
  170.  
  171.      [ENOMEM]       The new process requires more virtual memory
  172.                     than is allowed by the imposed maximum
  173.                     (_g_e_t_r_l_i_m_i_t(2)).
  174.  
  175.      [E2BIG]        The number of bytes in the new process's
  176.                     argument list is larger than the system-
  177.                     imposed limit.  The limit in the system as
  178.                     released is 20480 bytes (NCARGS in
  179.                     <_s_y_s/_p_a_r_a_m._h>.
  180.  
  181.      [EFAULT]       The new process file is not as long as indi-
  182.                     cated by the size values in its header.
  183.  
  184.      [EFAULT]       _P_a_t_h, _a_r_g_v, or _e_n_v_p point to an illegal
  185.                     address.
  186.  
  187.      [EIO]          An I/O error occurred while reading from the
  188.                     file system.
  189.  
  190. CCAAVVEEAATTSS
  191.      If a program is _s_e_t_u_i_d to a non-super-user, but is executed
  192.  
  193.  
  194.  
  195. Sprite v1.0               May 22, 1986                          3
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. EXECVE                C Library Procedures                 EXECVE
  203.  
  204.  
  205.  
  206.      when the real _u_i_d is ``root'', then the program has some of
  207.      the powers of a super-user as well.
  208.  
  209. SSEEEE AALLSSOO
  210.      exit(2), fork(2), execl(3), environ(7)
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261. Sprite v1.0               May 22, 1986                          4
  262.  
  263.  
  264.  
  265.